//
//  MainViewController.swift
//  SinaWeiBo
//
//  Created by ZKJ on 2017/5/17.
//  Copyright © 2017年 ZKJ. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    // MARK:- 懒加载属性
    fileprivate lazy var addButton : UIButton = UIButton(bgImgName: "tabbar_compose_button", imageName: "tabbar_compose_icon_add")
    
    // MARK:- 系统回调函数
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setUpAddButton()
    }
}

// MARK:- 设置UI界面
extension MainViewController {
    //设置发布按钮
    fileprivate func setUpAddButton() {
        // 1.将button添加到tabBar中
        tabBar.addSubview(addButton)
        
        // 2.设置位置
        addButton.center = CGPoint(x: tabBar.center.x, y: tabBar.bounds.size.height * 0.5)
        
        // 3.监听发布按钮的点击
        // Selector两种写法: 1>#selector(MainViewController.addBtnClick)
        addButton.addTarget(self, action: #selector(MainViewController.addBtnClick), for: .touchUpInside)
    }
}

// MARK:- 事件监听
extension MainViewController {
    @objc fileprivate func addBtnClick() {
        let vc = PublishVC()
        let nav = UINavigationController(rootViewController: vc)
        present(nav, animated: true, completion: nil)
    }
}

